package pl.polidea.imf.blackberry.service.statemachine;

import pl.polidea.imf.blackberry.util.Settings;

public class StateInit extends State {
	
	public static final int SUB_STATE_CHECK_IF_REGISTERED = 0;
	public static final int SUB_STATE_CHECK_PERMISSION = 1;
	
	public StateInit(int subState) {
		super(subState);
	}

	public State doWork() {
		State nextState = null;
		Settings settings = Settings.getInstance();
		String regKey = (String)settings.getField(Settings.KEY_REG_KEY);
		
		if(regKey==null){
			nextState = new StateRegistration(StateRegistration.SUB_STATE_REGISTRATION_GET_USER_DATA);
		}
		else{
			nextState = new StateLogin(StateLogin.SUB_STATE_LOGIN_LOGIN);
		}
		
		return nextState;
		
	}

}
